package org.ilovecode.buttons
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	public class TextFloorButton extends FloorButton
	{
		
		protected var _label:String;
		protected var _labelTextField:TextField;
		protected var _clickArea:MovieClip;
		
		public function TextFloorButton(id:int=999, name:String="", enabled:Boolean=true)
		{
			super(id, name, enabled);
		}
		
		override protected function construct():void
		{
			super.construct();
			
			_labelTextField = TextField(this.getChildByName("label_txt"));
			_labelTextField.autoSize = TextFieldAutoSize.LEFT;
			_labelTextField.embedFonts = true;
			
			_clickArea = MovieClip(this.getChildByName("clickArea_mc"));
		}
		
		override protected function initText():void
		{
			super.initText();
			
			if (id == 999)
				return;
			
			if (id > 0)
				label = "ETAŽA +" + id;
			else if (id == 0)
				label = "PRIZEMLJE";
			else
				label = "ETAŽA " + id;
				
		}
		
		override protected function initUI():void
		{
			super.initUI();
			
			_clickArea.width = _labelTextField.textWidth;
			_clickArea.height = _labelTextField.textHeight;
		}
		
		public function get label():String
		{
			return _label;
		}

		public function set label(value:String):void
		{
			_label = _labelTextField.text = value;
		}

	}
}